package nettydemo;/*

 */

import java.nio.ByteBuffer;

/**
 * @ClassName ReadOnlyBuffer
 * @Author Final
 * @Project DataStructures
 */
public class ReadOnlyBuffer {

    public static void main(String[] args) {
        ByteBuffer buffer=ByteBuffer.allocate(40);

        for (int i=1;i<=40;i++){
            buffer.put((byte)i);
        }

        buffer.flip();

        //得到一个制度buffer
        ByteBuffer byteBuffer = buffer.asReadOnlyBuffer();

        System.out.println(byteBuffer.getChar());

        while (byteBuffer.hasRemaining()){
            System.out.println(byteBuffer.get());
        }
    }
}
